package STUDENTS.TRANTHAIHA.DEMO;

import java.util.Scanner;

public class congtru {
	public static void main(String[] args) {
  
		
	   String strExit="";
	   do {
		   
	   
	   
			   
		Scanner sc = new Scanner(System.in);

		String tempt = "";
		String tempt2 = "";
		String str = "";
		String str2 = "";

		while (tempt.isEmpty()) {
			System.out.println("hay nhap gia tri cua a");
			tempt = sc.nextLine();
		}
		double a = Integer.parseInt(tempt);

		while (tempt2.isEmpty()) {
			System.out.println("hay nhap gia tri cua b");
			tempt2 = sc.nextLine();
		}
		double b = Integer.parseInt(tempt2);
		// moi chon phep toan

		do {
			System.out.println("moi chon: 0 - cong; 1 - tru; 2 - nhan; 3 - chia");
			str = sc.nextLine();
		} while (str.isEmpty() || Integer.parseInt(str) < 0 || Integer.parseInt(str) > 4);
 
		
		int d = Integer.parseInt(str);

		switch (d) {
		case 0:
			System.out.println("tong a va b la: " + (a + b));
			break;
		case 1:
			System.out.println("hieu a va b la: " + (a - b));
			break;
		case 2:
			System.out.println("hieu a va b la: " + (a * b));
			break;
		case 3:
			if(b < 0){
				System.out.println("phep tinh ko thuc hien dc");
			}else
			System.out.println("thuong a va b la: " + (a / b));
			break;
		 default : System.out.println("phep tinh ko thuc hien dc");
		 break;
		}
    System.out.println("ban chan chua y/n");
    strExit= sc.nextLine();
	   }while(!strExit.toUpperCase().equals("Y"));
	}
}
